package com.study.www.demo.config;

import com.study.www.demo.Application;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.joda.time.DateTime;
import org.springframework.stereotype.Component;

/**
 * AOP切面
 *
 * @author : Administrator.zhuyanpeng
 * @date : 2019/11/15 - 18:01
 */
@Component
@Slf4j
@Aspect
public class DemoAspect {


    public DemoAspect() {
        log.warn("DemoAOP 的 constructor ;启动时间=>"+new DateTime().toString(Application.DATEFORMAT));
    }

    @Pointcut("execution(public * com.study.www.demo.web..*(..))")
    public void webPoint(){
    }

    @Before("webPoint()")
    public void doBefore(JoinPoint joinPoint){
        log.warn("DemoAOP 的 doBefore ;启动时间=>"+new DateTime().toString(Application.DATEFORMAT));
    }


    @Around("webPoint()")
    public void doAround(ProceedingJoinPoint point) throws Throwable {
        log.warn("DemoAOP 的 doAround ;启动时间=>"+new DateTime().toString(Application.DATEFORMAT));
        point.proceed();
    }
}
